/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package net.hnilica.emailer;

import java.io.Serializable;
import java.text.DateFormat;
import java.util.Date;

/**
 *
 * @author swosh
 */
public class Termin implements Serializable, Comparable<Termin> {

    private String nazUlice;
    private Date terCis;

    public Termin() {
    }

    public Termin(String nazUlice, Date terCis) {
        this.nazUlice = nazUlice;
        this.terCis = terCis;
    }

    public String getNazev() {
        return nazUlice;
    }

    public void setNazev(String nazUlice) {
        this.nazUlice = nazUlice;
    }

    public Date getTerCis() {
        return terCis;
    }

    public void setTerCis(Date terCis) {
        this.terCis = terCis;
    }

    /**
     * Comparator for Termin. At the first compare terms of cleaning (terCis). On the bottom
     * (lesser ranking)  puts earlier date. Year 2000 is lesser then 1900. If dates is same then
     * sorts naem of street lixicongraphiclly by using String method compareToIgnoreCase.
     *
     * @param o Termin
     * @return int 1 before, 0 equals, -1 after or null
     */
    public int compareTo(Termin o) {
        int result = this.getTerCis().compareTo(o.getTerCis());
        if (result > 0) {
            return 1;
        } else if (result < 0) {
            return -1;
        } else {
            result = this.getNazev().compareToIgnoreCase(o.getNazev());
            if (result > 0) {
                return 1;
            } else if (result < 0) {
                return -1;
            } else {
                return 0;
            }
        }
    }

}
